/***********************************************************************
 * Module:  Tag.java
 * Author:  Voja
 * Purpose: Defines the Class Tag
 ***********************************************************************/

package model;

import java.util.*;

public class Tag {
   public int tagId;
   public java.lang.String tagText;
   
   public java.util.Collection<Photo> has_tag;
   
   
   /** @pdGenerated default getter */
   public java.util.Collection<Photo> getHas_tag() {
      if (has_tag == null)
         has_tag = new java.util.HashSet<Photo>();
      return has_tag;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorHas_tag() {
      if (has_tag == null)
         has_tag = new java.util.HashSet<Photo>();
      return has_tag.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newHas_tag */
   public void setHas_tag(java.util.Collection<Photo> newHas_tag) {
      removeAllHas_tag();
      for (java.util.Iterator iter = newHas_tag.iterator(); iter.hasNext();)
         addHas_tag((Photo)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newPhoto */
   public void addHas_tag(Photo newPhoto) {
      if (newPhoto == null)
         return;
      if (this.has_tag == null)
         this.has_tag = new java.util.HashSet<Photo>();
      if (!this.has_tag.contains(newPhoto))
      {
         this.has_tag.add(newPhoto);
         newPhoto.addHas_tag(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldPhoto */
   public void removeHas_tag(Photo oldPhoto) {
      if (oldPhoto == null)
         return;
      if (this.has_tag != null)
         if (this.has_tag.contains(oldPhoto))
         {
            this.has_tag.remove(oldPhoto);
            oldPhoto.removeHas_tag(this);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllHas_tag() {
      if (has_tag != null)
      {
         Photo oldPhoto;
         for (java.util.Iterator iter = getIteratorHas_tag(); iter.hasNext();)
         {
            oldPhoto = (Photo)iter.next();
            iter.remove();
            oldPhoto.removeHas_tag(this);
         }
      }
   }

}